package model

import (
	"time"
)

// Task 任务信息
type Task struct {
	Id        int64     `json:"id" xorm:"bigint pk"`
	Name      string    `json:"name" xorm:"varchar(100) notnull"`
	StartTime time.Time `json:"startTime" xorm:"timestamp notnull"`
	EndTime   time.Time `json:"endTime" xorm:"timestamp notnull"`

	ReceiverCount int       `json:"receiverCount" xorm:"int"`
	SucceedCount  int       `json:"succeedCount" xorm:"int"`
	FailedCount   int       `json:"failedCount" xorm:"int"`
	Status        int16     `json:"status" xorm:"smallint notnull"`
	PushStartTime time.Time `json:"pushStartTime" xorm:"timestamp"`
	PushEndTime   time.Time `json:"pushEndTime" xorm:"timestamp"`
	Process       float32   `json:"process" xorm:"double default 0.0 notnull"`

	CreatedId   int64     `json:"createdId" xorm:"smallint notnull"`
	CreatedName string    `json:"createdName" xorm:"smallint notnull"`
	CreatedTime time.Time `json:"createdTime" xorm:"timestamp notnull created"`
	UpdatedId   int64     `json:"updatedId" xorm:"smallint notnull"`
	UpdatedName string    `json:"updatedName" xorm:"smallint notnull"`
	UpdatedTime time.Time `json:"updatedTime" xorm:"timestamp notnull updated"`
}

// TaskMessage 任务消息
type TaskMessage struct {
	Id          int64  `json:"id" xorm:"bigint pk"`
	TaskId      int64  `json:"taskId" xorm:"bigint notnull index"`
	MessageType int16  `json:"messageType" xorm:"smallint notnull"`
	Payload     string `json:"payload" xorm:"json"`
}

// PushDetail 任务推送详情
type PushDetail struct {
	Id            int64
	TaskId        int64
	SellerCode    string
	SellerName    string
	RoomId        string
	RoomName      string
	SucceedCount  int
	FailedCount   int
	Filtered      bool
	FilteredCause string
}

// PushRecord 任务推送明细
type PushRecord struct {
	Id            int64
	TaskId        int64
	DetailId      int64
	TaskMessageId int64
	Successful    bool
	Cause         string
}
